package cn.edu.zut.internship.web.controller.notify;

import cn.edu.zut.internship.bean.sys.Result;
import cn.edu.zut.internship.bean.sys.SysUser;
import cn.edu.zut.internship.iservice.notify.ChatSV;
import cn.edu.zut.internship.iservice.notify.NoticeSV;
import cn.edu.zut.internship.web.utils.UserInfoUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/chat")
public class ChatController {
    @Reference
    ChatSV chatSV;
    /**
     * 获取聊天内容列表
     * @return
     */
    @RequestMapping("/getChatList")
    public Result getChatList(@RequestBody Map params){
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("sendAccount",userInfo.getUserAccount());
        result = chatSV.getChatList(params);
        return result;
    }

    /**
     * 发送一条聊天信息
     * @param params
     * @return
     */
    @RequestMapping("/sendChat")
    public Result sendChat(@RequestBody Map params){
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("sendAccount",userInfo.getUserAccount());
        params.put("userInfo",userInfo);
        result = chatSV.sendChat(params);
        return result;
    }

}
